<!-- 导入记录管理 -->
<template>
  <page-header-wrapper>
    <a-card class="table-card">
      <!-- 列表渲染 -->
      <GzTable
        ref="infoTableRef"
        :init-data="true"
        :req-table-data-func="reqTableDataFunc"
        :table-columns="tableColumns"
        :search-data="searchData"
        row-key="groupId"
        scrollX="800px"
      >
        <template #bodyCell="{ column, record }"> 
          <template v-if="column.key.split('.')[0] === 'num'">
            <a>{{ record[column.key.split('.')[1]] || '' }}</a>
          </template> 
          <template v-if="column.key === 'isRadius'">
            {{ record.isRadius=='1'?'是':'否' }}
          </template>
          <template v-if="column.key === 'succDown'">
            <a-button type="link" @click="fileDownFun(record.id,'1')">导入成功名单下载</a-button>
          </template>
          <template v-if="column.key === 'failDown'">
            <a-button type="link" @click="fileDownFun(record.id,'2')">导入失败名单下载</a-button>
          </template>
        </template>
      </GzTable>
    </a-card>
  </page-header-wrapper>
</template>

<script lang="ts" setup>

import { } from '@/api/manage'
import { ref, reactive, getCurrentInstance ,onMounted} from 'vue'
const { $infoBox, $access } = getCurrentInstance()!.appContext.config.globalProperties

// 商圈类型--查看下属商圈
const props = defineProps({
  sqlxNo: { type: String, default: '' }
})

const infoTableRef = ref()
let tableColumns = reactive([
  { key: 'importTime', title: '导入时间', dataIndex: 'importTime' },
  { key: 'oper', title: '操作人', dataIndex: 'oper'},
  { key: 'num.succNun', title: '导入成功商户数', dataIndex: 'succNun',align: 'center' },
  { key: 'num.failNum', title: '导入失败商户数', dataIndex: 'failNum',align: 'center' },
  { key: 'isRadius', title: '是否限制位置导入', dataIndex: 'isRadius'},
  { key: 'succDown', title: '导入成功名单', dataIndex: 'succDown',align: 'center'}, 
  { key: 'failDown', title: '导入失败名单', dataIndex: 'failDown',align: 'center'}
])


const searchData = ref({})
// 请求table接口数据
function reqTableDataFunc(params: any) {
  // var obj=Object.assign(params,{proxyNo:useUserStore().userInfo.belongInfoId})// 机构号
  // return req.list(API_URL_MARKETING_LIST, obj)
  return Promise.resolve({
    total: 1,
    records:[
      {
        id:'001',
        importTime:'2023-12-08 11:20:22',
        oper:'admin',
        isRadius: 1,
        succNun: 10,
        failNum: 5,
        radius: 2000,
      }
    ]
  })
}

function fileDownFun(id,type) {
  console.log('fileDownFun',id,type)
}

onMounted(() => {
  if(props.sqlxNo) searchData.value['sqlxText'] = props.sqlxNo
})

</script>
